import urllib2
from ntlm import HTTPNtlmAuthHandler
import os
import sys

def downloadFile(user,password,url):
	#passman
	passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
	passman.add_password(None, url, user, password)

	# create the NTLM authentication handler
	auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)

	# create and install the opener
	opener = urllib2.build_opener(auth_NTLM)
	urllib2.install_opener(opener)

	# retrieve the result

	response = urllib2.urlopen(url)
	data = response.read()
	with open("C:/17210.zip", "wb") as code:
		code.write(data)
    
if __name__ == '__main__':
	#main('fanying','fany@1234','http://10.1.64.21/SoftPlat/Common/GetFileStream.asp?Mode=0&FileUrl=E:\SoftPlat\QM\2\17210\4465416\&FileName=17210.rar')
	main('fanying','fany@1234','http://10.1.64.21/SoftPlat/qm/Done/ProblemShow.aspx?InstanceID=4465406')